const mongoose = require("mongoose");
main().catch(err => console.log(err));

async function main() {
    await mongoose.connect("mongodb://admin:L1Y1ru0%40%23123456@49.232.50.87/admin");
}

mongoose.connection.once("open", function () {
    console.info("============ok==============")
})


const schema = mongoose.Schema;

const peopleSchema = new schema({
    name: String,
    age: Number,
    gender: {
        type: Number,
        default: 2
    }
});

const PeopleModel = mongoose.model('People', peopleSchema);
const peopleModel = new PeopleModel({name: "qq", age: 99});
//peopleModel.save();

// PeopleModel.deleteMany({});


// PeopleModel.create([{name: "aa", age: 11}, {name: "bb", age: 22}, {name: "cc", age: 33}]).then(r => {
//     // console.info(r)
// })

// s

// PeopleModel.find({name: 'cc'}, {name: 1, age: 1, _id: 0}, function () {
//     console.info(arguments)
// })

PeopleModel.find({name: 'cc'},{name: 1, age: 1, _id: 0}, {limit:1}, function (err, docs) {
    console.info(err)
    console.info(docs)
})
